﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace HRM.Helper
{
    public class StatusMessage
    {
        /// <summary>
        /// Thông điệp hiển thị
        /// </summary>
        public string Status
        {
            get;
            private set;
        }

        /// <summary>
        /// Thời gian hiển thị
        /// </summary>
        public int TimeoutMilliseconds
        {
            get;
            private set;
        }

        public StatusType Type
        {
            get;
            private set;
        }

        public ImageSource IconSource
        {
            get
            {
                switch (Type)
                {
                    case StatusType.Done:
                        return new BitmapImage(new Uri("/Assets/Icons/done.png", UriKind.Relative));
                    case StatusType.Ban:
                        return new BitmapImage(new Uri("/Assets/Icons/bane.png", UriKind.Relative));
                    case StatusType.Error:
                        return new BitmapImage(new Uri("/Assets/Icons/error.png", UriKind.Relative));
                    case StatusType.Info:
                        return new BitmapImage(new Uri("/Assets/Icons/info.png", UriKind.Relative));
                    default:
                        return new BitmapImage(new Uri("/Assets/Icons/warning.png", UriKind.Relative));
                }
            }
        }

        public StatusMessage(string status, int timeout, StatusType type)
        {
            Status = status;
            TimeoutMilliseconds = timeout;
            Type = type;
        }

        public static StatusMessage DatabaseErrorMessage()
        {
            StatusMessage status = new StatusMessage("Đã xảy ra lỗi CSDL", 3000, StatusType.Error);
            return status;
        }

        public static StatusMessage CompletedMessage()
        {
            StatusMessage status = new StatusMessage("Thành công", 3000, StatusType.Done);
            return status;
        }

        public static StatusMessage EmptyInputMessage()
        {
            StatusMessage status = new StatusMessage("Không được bỏ trống", 3000, StatusType.Error);
            return status;
        }

        public static StatusMessage KeyDependentMessage()
        {
            return new StatusMessage("Lỗi khóa phụ thuộc", 3000, StatusType.Error);
        }
    }

    public enum StatusType
    {
        Done,
        Warning,
        Ban,
        Error,
        Info
    }
}
